import { createApp } from "vue";
import App from "./App.vue";
import router from "./router";
import store from "./store"; // 确保路径正确
import ElementPlus from "element-plus";
import zhCn from "element-plus/es/locale/lang/zh-cn"; // 引入中文语言包
import "element-plus/dist/index.css"; // 引入样式文件
import "./assets/styles/global.scss"; // 引入全局样式
import * as echarts from "echarts";
import AxiosPlugin from "./plugins/axios"; // 引入封装的 axios 插件
import WebSocketManager from "./utils/websocket"; // 引入 websocket 管理器
import WebSocketPlugin from "./plugins/websocket"; // 引入 WebSocket 插件
import { MdEditor } from 'md-editor-v3'
import 'md-editor-v3/lib/style.css'

// 引入iconfont
import './assets/font/iconfont.css'

const app = createApp(App);

// elementui
import * as ElementPlusIconsVue from "@element-plus/icons-vue";

// 注册 element-plus 图标
for (const [key, component] of Object.entries(ElementPlusIconsVue)) {
  app.component(key, component);
}

// 将 echarts 挂载到全局
app.config.globalProperties.$echarts = echarts;

// 使用 ElementPlus 并设置语言为中文
app.use(ElementPlus, {
  locale: zhCn,
});
app.use(router);
app.use(store); // 注册 Vuex store
app.use(AxiosPlugin); // 注册 axios 插件
app.use(WebSocketPlugin, {
  url: "ws://192.168.1.165:8080/socket/task", // 默认 WebSocket URL
  // url: "ws://182.26.1.165:8080/socket/task", // 默认 WebSocket URL
});
app.component('MdEditor', MdEditor) // 全局注册组件
app.mount("#app");
